package redis

import (
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
	"month5/common/nacos"
)

var RDB *redis.Client

func InitRedis() {
	nac := nacos.Config.Redis
	RDB = redis.NewClient(&redis.Options{
		Addr:     nac.Addr,
		Password: nac.Password, // no password set
		DB:       nac.DB,       // use default DB
	})

	pong, err := RDB.Ping(context.Background()).Result()
	fmt.Println(pong, err)
	fmt.Println("redis success")
}
